
#ifndef _DRIVER_LSM6DSRTR_H
#define _DRIVER_LSM6DSRTR_H

#include "arm_math.h"

#define LSM6DSR_IIC_ADDR  0XD4
#define LSM6DSR_INT1_CTRL 0X0D
#define LSM6DSR_INT2_CTRL 0X0E

#define LSM6DSR_WHO_AM_I  0X0F
#define LSM6DSR_ID        0X6B

#define LSM6DSR_CTRL1_XL 0X10
#define LSM6DSR_CTRL2_G  0X11
#define LSM6DSR_CTRL3_C  0X12
#define LSM6DSR_CTRL4_C  0X13
#define LSM6DSR_CTRL5_C  0X14
#define LSM6DSR_CTRL6_C  0X15
#define LSM6DSR_CTRL7_G  0X16
#define LSM6DSR_CTRL8_XL 0X17
#define LSM6DSR_CTRL9_XL 0X18
#define LSM6DSR_CTRL10_C 0X19

#define LSM6DSR_STATUS_REG  0X1E

#define LSM6DSR_OUT_TEMP_L  0X20
#define LSM6DSR_OUT_TEMP_H  0X21

#define LSM6DSR_OUTX_L_GYRO 0X22
#define LSM6DSR_OUTX_H_GYRO 0X23
#define LSM6DSR_OUTY_L_GYRO 0X24
#define LSM6DSR_OUTY_H_GYRO 0X25
#define LSM6DSR_OUTZ_L_GYRO 0X26
#define LSM6DSR_OUTZ_H_GYRO 0X27

#define LSM6DSR_OUTX_L_ACC  0X28
#define LSM6DSR_OUTX_H_ACC  0X29
#define LSM6DSR_OUTY_L_ACC  0X2A
#define LSM6DSR_OUTY_H_ACC  0X2B
#define LSM6DSR_OUTZ_L_ACC  0X2C
#define LSM6DSR_OUTZ_H_ACC  0X2D

#define LSM6DSR_I3C_BUS_AVB 0x62
#define PROPERTY_ENABLE     (1U)
#define PROPERTY_DISABLE    (0U)


typedef enum ACC_LPF_1
{
	ACC_USE_LPF1 = 0<<1,
	ACC_USE_LPF2 = 1<<1,
}ACC_LPF_USE_SET_E;


typedef enum ACC_ODR_SET
{
	ACC_ODR_1_6HZ  = 11 << 4,
	ACC_ODR_12_5HZ = 1  << 4,
	ACC_ODR_26HZ   = 2  << 4,
	ACC_ODR_52HZ   = 3  << 4,
	ACC_ODR_104HZ  = 4  << 4,
	ACC_ODR_208HZ  = 5  << 4,
	ACC_ODR_417HZ  = 6  << 4,
	ACC_ODR_833HZ  = 7  << 4,
	ACC_ODR_1660HZ = 8  << 4,
	ACC_ODR_3330HZ = 9  << 4,
	ACC_ODR_6660HZ = 10 << 4
} ACC_ODR_SET_E;


typedef enum GYRO_ODR_SET
{
	GYRO_ODR_12_5HZ = 1 << 4,
	GYRO_ODR_26HZ   = 2 << 4,
	GYRO_ODR_52HZ   = 3 << 4,
	GYRO_ODR_104HZ  = 4 << 4,
	GYRO_ODR_208HZ  = 5 << 4,
	GYRO_ODR_417HZ  = 6 << 4,
	GYRO_ODR_833HZ  = 7 << 4,
	GYRO_ODR_1660HZ = 8 << 4,
	GYRO_ODR_3330HZ = 9 << 4,
	GYRO_ODR_6660HZ = 10 << 4
} GYRO_ODR_SET_E;


typedef enum XL_HM_MODE_SET
{
	XL_HM_MODE_ENABLE  = 0 << 4, 
	XL_HM_MODE_DISABLE = 1 << 4
} XL_HM_MODE_SET_E;


typedef enum G_HM_MODE_SET
{
	G_HM_MODE_ENABLE  = 0 << 7, 
	G_HM_MODE_DISABLE = 1 << 7,
} G_HM_MODE_SET_E;


typedef enum
{
	LSM6DSR_2g  = 0 << 2,
	LSM6DSR_16g = 1 << 2,
	LSM6DSR_4g  = 2 << 2,
	LSM6DSR_8g  = 3 << 2,
} ACC_G_SET_E;


typedef enum
{
	LSM6DSR_125dps  = 2,
	LSM6DSR_250dps  = 0,
	LSM6DSR_500dps  = 4,
	LSM6DSR_1000dps = 8,
	LSM6DSR_2000dps = 12,
	LSM6DSR_4000dps = 1,
} GYRO_DPS_SET_E;


typedef enum
{
	LSM6DSR_I3C_DISABLE       = 0x80,
	LSM6DSR_I3C_ENABLE_T_50us = 0x00,
	LSM6DSR_I3C_ENABLE_T_2us  = 0x01,
	LSM6DSR_I3C_ENABLE_T_1ms  = 0x02,
	LSM6DSR_I3C_ENABLE_T_25ms = 0x03,
} lsm6dsr_i3c_disable_t;


extern void lsm6dsr_init(void);
extern void get_lsm6dsr_gyro_z(float32_t *ang_spd);
extern void get_lsm6dsr_gyro_xyz(float32_t *gyro);
extern void get_lsm6dsr_accel_xyz(float32_t *accel);
#endif

